package com.gorkr.hot100.medium;

import java.util.ArrayList;
import java.util.LinkedList;
import java.util.Stack;

/**
 * @author 张心宇 <zhangxinyu20@kuaishou.com>
 * Created on 2023-01-06
 */
public class M155MinStack {
    private Stack<Integer> stack;
    private Stack<Integer> minStack;

    public M155MinStack() {
        stack = new Stack<>();
        minStack = new Stack<>();
        minStack.push(Integer.MAX_VALUE);

    }

    public void push(int val) {
        stack.push(val);
        minStack.push(Math.min(minStack.peek(), val));
    }

    public void pop() {
        stack.pop();
        minStack.pop();

    }

    public int top() {
        return stack.peek();
    }

    public int getMin() {
        return minStack.peek();
    }
}
